#include "parser.h"
#include "Globe.h"
#include <iostream>

unique_ptr<BaseExpAST> parser::parseExp()
{
    return this->parseCommaExp();
}

unique_ptr<BaseExpAST> parser::parsePrimaryExp()
{
    unique_ptr<BaseExpAST>ret;
    switch (this->lexer->next_token())
    {
    case TOK::LPAREN:
        this->lexer->match(TOK::LPAREN);
        ret = this->parseExp();
        this->lexer->match(TOK::RPAREN);
        return ret;
    case TOK::NUMBER:
        return this->parseNumber();
    case TOK::IDENTIFIER:
        return this->parsePostfixExp();

    default:
        std::cerr << "unexpected token." << std::endl;
        exit(-1);
    }
}
